<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script type="module">
      import MyPromise from './MyPromise.js'
      var resolved = MyPromise.resolve(42);
      var rejected1 = MyPromise.reject(-1);
      var rejected2 = MyPromise.reject(Infinity);
      var rejected3 = new MyPromise((resolve, reject) => {
          setTimeout(() => {
              reject('延迟失败')
          }, 20)
      })

      MyPromise.any([resolved, rejected1, rejected2])
      .then(result => {
        console.log('any resolve', result); // 42
      });

      MyPromise.any([rejected3, rejected1, rejected2])
      .catch(results => {
        console.dir(results); 
      });

      MyPromise.allSettled([resolved, rejected1, rejected2, rejected3])
      .then(results => {
        console.log('allSettled', results); 
      });
    </script>
  </body>
</html>
